<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>io.jenkins.jenkinsfile-runner</groupId>
    <artifactId>packaging-parent-pom</artifactId>
    <version>${revision}${changelist}</version>
    <relativePath>../packaging-parent-pom</relativePath>
  </parent>

  <artifactId>vanilla-package</artifactId>
  <description>Defines plugins which should be included into the Vanilla bundle</description>

  <properties>
    <jfr.name>jenkinsfile-runner-vanilla</jfr.name>
    <jfr.packaging.skip.assembly>true</jfr.packaging.skip.assembly>
    <skip.integration.tests>true</skip.integration.tests>
    <testcontainers.version>1.17.6</testcontainers.version>
    <elasticsearch.version>7.17.6</elasticsearch.version>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>default-testResources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
            <configuration>
              <skip>false</skip>
              <resources>
                <resource>
                  <directory>src/test/resources</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <!-- Extra Dependencies for Vanilla -->
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>pipeline-utility-steps</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>git</artifactId>
    </dependency>
    <!-- Exclude this outdated plugin since it will fail with higher managed dependencies
         coming from the Jenkins core parent bom -->
    <!--
    <dependency>
      <groupId>io.jenkins.plugins</groupId>
      <artifactId>pipeline-as-yaml</artifactId>
      <version>0.16-rc</version>
      <exclusions>
        <exclusion>
          <groupId>com.google.code.gson</groupId>
          <artifactId>gson</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    -->
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>job-dsl</artifactId>
      <version>1.81</version>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>templating-engine</artifactId>
      <version>2.3</version>
      <exclusions>
        <exclusion>
          <groupId>com.google.errorprone</groupId>
          <artifactId>error_prone_annotations</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>http_request</artifactId>
    </dependency>

    <!-- Upper bounds -->
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-text</artifactId>
      <version>1.10.0</version>
    </dependency>

    <!-- Tests -->
    <dependency>
      <groupId>com.github.stefanbirkner</groupId>
      <artifactId>system-rules</artifactId>
      <version>1.19.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>testcontainers</artifactId>
      <version>${testcontainers.version}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-annotations</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>elasticsearch</artifactId>
      <version>${testcontainers.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.elasticsearch.client</groupId>
      <artifactId>elasticsearch-rest-client</artifactId>
      <version>${elasticsearch.version}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpcore</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpclient</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.elasticsearch.client</groupId>
      <artifactId>transport</artifactId>
      <version>${elasticsearch.version}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>net.sf.jopt-simple</groupId>
          <artifactId>jopt-simple</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>run-its</id>
      <properties>
        <skip.integration.tests>false</skip.integration.tests>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>3.2.0</version>
            <executions>
              <execution>
                <id>add-integration-test-sources</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>add-test-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>src/test-integration/java</source>
                  </sources>
                </configuration>
              </execution>
              <execution>
                <id>add-integration-test-resources</id>
                <phase>generate-test-resources</phase>
                <goals>
                  <goal>add-test-resource</goal>
                </goals>
                <configuration>
                  <resources>
                    <resource>
                      <filtering>true</filtering>
                      <directory>src/test-integration/resources</directory>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.22.2</version>
            <executions>
              <execution>
                <id>integration-tests</id>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <includes>
                    <include>**/*.java</include>
                  </includes>
                  <groups>io.jenkins.jenkinsfile.runner.vanilla.JFRIntegrationTest</groups>
                  <skipTests>${skip.integration.tests}</skipTests>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration combine.self="override">
              <excludes>
                <exclude>**/its/**.java</exclude>
              </excludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
